<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Binh
 * Date: 1/7/14
 * Time: 9:23 AM
 * To change this template use File | Settings | File Templates.
 */

use \Model;

class Controller_Singer extends Controller{
    private $view;

    public function __construct(){
        //Cài đặt view
        $this->view = View::forge('home/layout');
        $this->view->head = View::forge('home/head');
        $this->view->header = View::forge('home/header');
        $this->view->footer = View::forge('home/footer');
        $this->view->layout_singer = View::forge('home/layout_singer');

        //Cài đặt biến toàn cục
        $this->view->set_global('site', 'layout_singer');
    }

    private function set_layout($singer, $songs){
        $this->view->set_global('singer', $singer);
        $this->view->set_global('songs', $songs);

        return $this->view;
    }

    public function action_communication($singer_id){
        $singer = \Model\Singer::get_communication($singer_id);

        if($singer != array()){
            return $this->set_layout($singer[0], \Model\Song::get_singer_id($singer[0]['SINGER_ID']));
        }
        else{
            return $this->set_layout(null, null);
        }
    }
}